if _G.XLibrary == nil then _G.XLibrary = {} end

XLibrary.XLIB_SPEW = true -- 如果设置为false，则不会打印xlib的一切输出消息

XLibrary.XLIB_VERSION = "0.0.0" -- 版本号
XLibrary.AUTHOR_NAME = "XavierCHN" -- 作者

-- 重写 XLibrary中的print
XLibrary.XLIB_PREFIX = "[XLIB] "

local _print = print
local function print(...)
    if XLibrary.XLIB_SPEW then
        _print(XLibrary.XLIB_PREFIX, ...)
    end
end

print(string.format("Begin to load XLibrary Version %s", XLibrary.XLIB_VERSION))

-- 如果在引擎外，载入库
if not GameRules then
    
    require('xlib.xclass')
    require('xlib.xvalvelib')
end

local modules = {
    "xutil",
    "xinventory",
}

local bLoadSuccess = true

for _, mod in pairs(modules) do
    local s, e = pcall(require, "xlib." .. mod)
    if not s then
        print("Failed to load", mod, e)
        bLoadSuccess = false
    else
        print(string.format("Load %s finished!", mod))
    end
end

assert(bLoadSuccess, "Failed to load xLib!")

print("Load xLib finished!")